0.05 0.1 0.3 0.5 1 1.5
14 146 280 108 40 5766
The code is in this repository. Feel free to share and comment.
---
title: "The squirrel problem"
output:
flexdashboard::flex_dashboard:
storyboard: true
social: menu
source: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(leaflet)
library(raster)
# Load path and map
path_points = read.csv("Files/path_coordinates_solution.csv")
small_img_plot = raster("Files/GlobCover_Spain.tif")
```
### The map
```{r}
# The raster is too big to be displayed so let's shrink it
agg_small_img_plot = raster::aggregate(small_img_plot,fact=3)
# Make a leaflet visualization
pal2 = colorNumeric("RdYlGn", domain = NULL)
ll_map = leaflet() %>%
# Base maps
addProviderTiles('Esri.WorldGrayCanvas',group="Esri Grey") %>%
addProviderTiles('Esri.WorldTopoMap',group="Esri Topo") %>%
addProviderTiles("Esri.WorldImagery", group = "Esri Image") %>%
# # Roughness info
addRasterImage(agg_small_img_plot, opacity = 0.5,colors=pal2, group="Roughness map") %>%
addLegend(position="bottomleft", pal = pal2, values = values(agg_small_img_plot),
title = "Roughness",
opacity = 1) %>%
# path info
addPolylines(lng=path_points$lon,lat=path_points$lat,group="Path") %>%
# Control groups
addLayersControl(
baseGroups = c("Esri Grey","Esri Image","Esri Topo"),
overlayGroups = c("Roughness map", "Path"),
options = layersControlOptions(collapsed = F)
)
ll_map
```
### The path
```{r, echo=FALSE, message=FALSE, warning=FALSE}
small_img = reclassify(small_img_plot,c(100,NA,NA))
values_glob = values(small_img)
table(values_glob[path_points$n])
barplot(table(values_glob[path_points$n]))
```
***
### Info
The code is in [this](https://github.com/jsga/GlobCover_maps_squirrel) repository. Feel free to share and comment.